package com.ruoyi.project.mealOrde.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mealOrde.domain.MealOrder;
import com.ruoyi.project.mealOrde.service.IMealOrderService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 套餐订单Controller
 * 
 * @author wyh
 * @date 2024-08-16
 */
@RestController
@RequestMapping("/meal/mealOrder")
public class MealOrderController extends BaseController
{
    @Autowired
    private IMealOrderService mealOrderService;

    /**
     * 查询套餐订单列表
     */
    @PreAuthorize("@ss.hasPermi('meal:mealOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(MealOrder mealOrder)
    {
        startPage();
        List<MealOrder> list = mealOrderService.selectMealOrderList(mealOrder);
        return getDataTable(list);
    }

    /**
     * 导出套餐订单列表
     */
    @PreAuthorize("@ss.hasPermi('meal:mealOrder:export')")
    @Log(title = "套餐订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MealOrder mealOrder)
    {
        List<MealOrder> list = mealOrderService.selectMealOrderList(mealOrder);
        ExcelUtil<MealOrder> util = new ExcelUtil<MealOrder>(MealOrder.class);
        util.exportExcel(response, list, "套餐订单数据");
    }

    /**
     * 获取套餐订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('meal:mealOrder:query')")
    @GetMapping(value = "/{outTradeNo}")
    public AjaxResult getInfo(@PathVariable("outTradeNo") String outTradeNo)
    {
        return success(mealOrderService.selectMealOrderByOutTradeNo(outTradeNo));
    }

    /**
     * 新增套餐订单
     */
    @PreAuthorize("@ss.hasPermi('meal:mealOrder:add')")
    @Log(title = "套餐订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MealOrder mealOrder)
    {
        return toAjax(mealOrderService.insertMealOrder(mealOrder));
    }

    /**
     * 修改套餐订单
     */
    @PreAuthorize("@ss.hasPermi('meal:mealOrder:edit')")
    @Log(title = "套餐订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MealOrder mealOrder)
    {
        return toAjax(mealOrderService.updateMealOrder(mealOrder));
    }

    /**
     * 删除套餐订单
     */
    @PreAuthorize("@ss.hasPermi('meal:mealOrder:remove')")
    @Log(title = "套餐订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{outTradeNos}")
    public AjaxResult remove(@PathVariable String[] outTradeNos)
    {
        return toAjax(mealOrderService.deleteMealOrderByOutTradeNos(outTradeNos));
    }
}
